#pragma once

#include "StlDef.h"

#include <sstream>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <ctype.h>
#include <algorithm>

#ifdef EA_STL_ENABLED

	#include "EASTL/string.h"

	template<class Elem, class Traits, class Alloc> 
	inline std::basic_ostream<Elem, Traits>& 
		operator<<( std::basic_ostream<Elem, Traits>& o_stream,
					const eastl::basic_string<Elem, Alloc>& i_string)
	{	// string in stream
		return o_stream << i_string.c_str();
	}

	template<class Elem, class Traits, class Alloc> 
	inline std::basic_istream<Elem, Traits>& 
		operator>>(	std::basic_istream<Elem, Traits>& i_stream,
					eastl::basic_string<Elem, Alloc>& o_string)
	{	// string from a stream
		static std::basic_string<Elem, Traits> s_theString;
		std::basic_istream<Elem, Traits>& retVal = ( i_stream >> s_theString );
		if(retVal)
			o_string = s_theString.c_str();
		return retVal;
	}


	template<class Elem, class Traits, class Alloc> 
	inline std::basic_istream<Elem, Traits>& 
		getline(	std::basic_istream<Elem, Traits>& i_stream,
					eastl::basic_string<Elem, Alloc>& o_string,
		const Elem i_delim)
	{	// get characters into string, discard delimiter
		static std::basic_string<Elem, Traits> s_theString;
		std::basic_istream<Elem, Traits>& retVal = getline(i_stream, s_theString, i_delim);
		if(retVal)
			o_string = s_theString.c_str();
		return retVal;
	}

	template<class Elem, class Traits, class Alloc> 
	inline std::basic_istream<Elem, Traits>& 
		getline(	std::basic_istream<Elem, Traits>& i_stream,
					eastl::basic_string<Elem, Alloc>& o_string)
	{	// get characters into string, discard newline
		return (getline(i_stream, o_string, '\n'));
	}

#endif

inline void ToLowerString(STL::string& io_string)
{
#ifdef EA_STL_ENABLED
	io_string.make_lower();
#else
	STL::transform(io_string.begin(), io_string.end(), io_string.begin(), tolower);
#endif
}
